<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>精确查找</title>
<!-- Bootstrap -->
	<link href="{SHUAFEN_STATICS_PATH}css/bootstrap.min.css"
		  rel="stylesheet">
	<link href="{SHUAFEN_STATICS_PATH}css/profile_style.css" rel="stylesheet">
	<link href="{SHUAFEN_STATICS_PATH}css/response.css" rel="stylesheet">
	<link href="{SHUAFEN_STATICS_PATH}css/bootstrapValidator.css" rel="stylesheet">
	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="{SHUAFEN_STATICS_PATH}js/lib/jquery.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script src="{SHUAFEN_STATICS_PATH}js/lib/bootstrap.min.js"></script>
	<script src="{SHUAFEN_STATICS_PATH}js/lib/bootstrapValidator.min.js"></script>
	<script src="{SHUAFEN_STATICS_PATH}js/lib/style.js"></script>
	<script type="text/javascript">
	$(function (){
		
		$('#downloadForm').bootstrapValidator({
       live: 'disabled',
       message: '必须大于零',
       feedbackIcons: {
           valid: 'glyphicon glyphicon-ok',
           invalid: 'glyphicon glyphicon-remove',
           validating: 'glyphicon glyphicon-refresh'
       },
       fields: {
           startPos: {
               validators: {
                   notEmpty: {
                       message: '<span style="font-size:1.2em;">不能为空！</span>'
                   }
               }
           }
       }
	 });
		setup(["全部","全部"]);
	});
	var num = null;
	function search(){
		num = null;
		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=do_search',
			method : 'post',
			data : $("#downloadForm").serialize(),
			success : function(rs) {
				if(!rs.status) {
					$("#modelText").text(rs.msg);
					$('#myModal').modal();
				}else {
					num = rs.num;
					$("#download").css("display", "block");
					$("#downloadMsg").html("<span style='font-size:1.2em;'>共找到记录" + rs.num + "条，每次最多可下载" + rs.pagesize + "条记录，输入记录开始位置，点击导出通讯录按钮，即可导出通讯录文件！</span>");
				}
			},
			dataType : 'json'
		});
	}
	function download(){
		//检查是否有权限下载
		var startPosition = $('#startPos').val();
		if(num === null){
			return;
		}
		if(startPosition > num && num != null){
			$("#modelText").text("下载位置不可超过总条数");
			$('#myModal').modal();
			return;
		}
		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=check_download',
			method : 'post',
			data : $("#downloadForm").serialize(),
			success : function(rs) {
				if(!rs.status){
					$("#modelText").text(rs.msg);
					$('#myModal').modal();
				}else{
					$("#downloadForm").submit();
				}

			},
			dataType : 'json'
		});

	}

	//当页面加载完成后，初始化一级行业列表
	var option = '<option value="">全部</option>';
	$(function (){
		setup();
		//preselect('河南省','新乡市');

		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=getIndustry',
			method : 'get',
			success : function (rs){
				$("#level_1").append(option);
				for (var i = 0; i < rs.length; i ++) {
					$("#level_1").append('<option value="'+rs[i].id+'">'+rs[i].industry_name+'</option>');
				}
			},
			dataType : 'json'
		});
		$("#industry").on("change",'#level_1',function (){
			initIndustry($(this).val(),'level_2');
		});
		$("#industry").on("change",'#level_2',function (){
			initIndustry($(this).val(),'level_3');
		});
	});
	function initIndustry(pid,level){
		if(!pid) return;
		$("#"+level).parent().remove();
		$("#level_3").parent().remove();
		var industry_type_name = level=='level_2'?'二级行业':'三级行业';
		var industry_id_name = level=='level_2'?'industry_two':'industry_three';

		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=getIndustry&pid='+pid,
			method : 'get',
			success : function (rs){
				if(!rs.length){
					return;
				}
				var str = '<div class="form-group input-group">'+
						'<span class="input-group-addon">'+industry_type_name+'</span>'+
						'<select id="'+level+'" class=" form-control" name="'+industry_id_name+'"></select>'+
						'</div>';
				$("#industry").append(str);
				$("#"+level).append(option);
				for (var i = 0; i < rs.length; i ++) {
					$("#"+level).append('<option value="'+rs[i].id+'">'+rs[i].industry_name+'</option>');
				}

			},
			dataType : 'json'
		});
	}
</script>
</head>
<body style="margin: 0 5px;">
	<div class="prolist">
		<form id="downloadForm" method="post" action="index.php?m=shuafen&c=web&a=do_search_download">
			<div class="form-group input-group">
				<span class="input-group-addon">性别</span>
				<div class="form-control">
					<label class="checkbox-inline"> <input type="radio"
														   name="sex"  value="-1"
														   checked>不限
					</label><label class="checkbox-inline"> <input type="radio"
						name="sex"  value="0"
						>男
					</label> <label class="checkbox-inline"> <input type="radio"
						name="sex"  value="1"
						>
						女
					</label>
				</div>
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">省份</span>
				<select id="s1" class="form-control" name="province"></select>

			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">城市</span> <select id="s2"
																  name="city" class="form-control">
			</select>
			</div>
			<div id="industry">
				<div class="form-group input-group">
					<span class="input-group-addon">一级行业</span>
					<select id="level_1" name="industry_one" class=" form-control">
					</select>
				</div>
			</div>
			<div style="color : red;"></div>
			<input type="button" class="btn btn-primary btn-lg btn-block"
				value="查找" onclick="javascript:search();" />
				<br />
		<div id="download" style="display : none;">
			<div id="downloadMsg"  class="form-group">
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">开始位置</span> <input
					type="number" class="form-control" id="startPos" name="startPos" value="1" min="1"
					placeholder="开始记录数" data-bv-greaterthan="true" data-bv-greaterthan-value="1" data-bv-greaterthan-message="必选填写大于1的数字" data-bv-notempty="true" data-bv-notempty-message="不可为零">
			</div>
			<input type="button" class="btn btn-primary btn-lg btn-block"
				value="导出通讯录" onclick="javascript:download();" />
		</div>
		</form>
		<div class="clearfix"></div>
	</div>
	{template 'shuafen', 'footer'}
	<!--<nav>-->
     <!-- -->
<!--<dl>-->
	<!--<dt>-->
		<!--<a href="./index.html"><img-->
			<!--src="{SHUAFEN_STATICS_PATH}images/nav1.png" width="65" height="35" /></a>-->
	<!--</dt>-->
	<!--<dd>-->
		<!--<a href="./index.html">首页</a>-->
	<!--</dd>-->
<!--</dl>-->
<!--<dl>-->
	<!-- -->
	<!--<dt>-->
		<!--<a href="./search.html"><img-->
			<!--src="{SHUAFEN_STATICS_PATH}images/nav2.png" width="65" height="35" /></a>-->
	<!--</dt>-->
	<!--<dd>-->
		<!--<a href="./search.html">精确查找</a>-->
	<!--</dd>-->
	<!-- -->
	<!-- -->
<!--</dl>-->
<!--<dl>-->
	<!--<dt>-->
		<!--<a href="./novice.html"><img-->
			<!--src="{SHUAFEN_STATICS_PATH}images/nav3.png" width="65" height="35" /></a>-->
	<!--</dt>-->
	<!--<dd>-->
		<!--<a href="./novice.html">新手教程</a>-->
	<!--</dd>-->
<!--</dl>-->

<!--<dl>-->
	<!--<dt>-->
		<!--<a href="http://www.udppvr.cn:80/profile/toUserCenter.do"><img-->
			<!--src="{SHUAFEN_STATICS_PATH}images/nav4.png" width="65" height="35" /></a>-->
	<!--</dt>-->
	<!--<dd>-->
		<!--<a href="http://www.udppvr.cn:80/profile/toUserCenter.do">会员中心</a>-->
	<!--</dd>-->
<!--</dl>-->


<!--<div class="clearfix"></div>-->
    <!--</nav>-->
	<!--prolist/-->
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">下载名片夹提示</h4>
				</div>
				<div class="modal-body" id="modelText"></div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
</body>
<script src="<?php echo JS_PATH?>city.js"></script>
</html>